package ee.parameterConverter.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import ee.parameterConverter.ValidationResultCollector;

public class ValidationResultCollectorImpl implements ValidationResultCollector {

	private Map<String,Throwable> _results;

	public ValidationResultCollectorImpl()
	{
		_results = new HashMap<String, Throwable>();
	}
	
	@Override
	public void processException(List<String> parameterPath, Throwable exception) {
		
		StringBuilder pathBuilder = new StringBuilder(); 
		
		boolean first = true;
		
		for (String pathPart : parameterPath)
		{
			if (first)
			{
				first = false;
			} else
			{
				pathBuilder.append(".");
			}
			pathBuilder.append(pathPart);
		}
		
		_results.put(pathBuilder.toString(), exception);
	}

	public Map<String, Throwable> getResults()
	{
		return _results;
	}
}
